﻿<%@ Page Language="C#" AutoEventWireup="true" CodeFile="GetServices.aspx.cs" Inherits="GetServices" %>

<input type="checkbox" id="select_all_services" />
<label for="select_all_services">All Buttons</label>
<div class="wrapper_check">
    <ul id="services_list">
        <%--<li class="deleted">
            <input type="checkbox" name="s_deleted" id="search_in_deleted_services" />
            <label for="search_in_deleted_services">Include Deleted Services</label>
        </li>--%>
        <%= this.GetUIData() %>
       <%-- <li>
            <input type="checkbox" checked id="inputee1_1" class="inputcheckbox" name="s[]" value="578959" />
            <label class="selectbox_label" for="inputee1_1">
                <strong>Database Builder Service 1</strong>
            </label>
        </li>
        <li>
            <input type="checkbox" checked id="inputee1_2" class="inputcheckbox" name="s[]" value="578960" />
            <label class="selectbox_label" for="inputee1_2">
                <strong>Database Builder Service 2</strong>
            </label>
        </li>
        <li>
            <input type="checkbox" checked id="inputee1_3" class="inputcheckbox" name="s[]" value="581224" />
            <label class="selectbox_label" for="inputee1_3">
                <strong>Database Builder Service 3</strong>
            </label>
        </li>
        <li>
            <input type="checkbox" checked id="inputee1_4" class="inputcheckbox" name="s[]" value="578961" />
            <label class="selectbox_label" for="inputee1_4">
                <strong>Postback Service 1</strong>
            </label>
        </li>
        <li>
            <input type="checkbox" checked id="inputee1_5" class="inputcheckbox" name="s[]" value="578957" />
            <label class="selectbox_label" for="inputee1_5">
                <strong>Record On-Device Service 1</strong>
            </label>
        </li>
        <li>
            <input type="checkbox" checked id="inputee1_6" class="inputcheckbox" name="s[]" value="579102" />
            <label class="selectbox_label" for="inputee1_6">
                <strong>Record On-Device Service 2</strong>
            </label>
        </li>
        <li>
            <input type="checkbox" checked id="inputee1_7" class="inputcheckbox" name="s[]" value="581226" />
            <label class="selectbox_label" for="inputee1_7">
                <strong>Record On-Device Service 3</strong>
            </label>
        </li>
        <li>
            <input type="checkbox" checked id="inputee1_8" class="inputcheckbox" name="s[]" value="578587" />
            <label class="selectbox_label" for="inputee1_8">
                <strong>Record Online Service 1</strong>
            </label>
        </li>
        <li>
            <input type="checkbox" checked id="inputee1_9" class="inputcheckbox" name="s[]" value="579100" />
            <label class="selectbox_label" for="inputee1_9">
                <strong>Record Online Service 2</strong>
            </label>
        </li>
        <li>
            <input type="checkbox" checked id="inputee1_10" class="inputcheckbox" name="s[]" value="579101" />
            <label class="selectbox_label" for="inputee1_10">
                <strong>Record Online Service 3</strong>
            </label>
        </li>
        <li>
            <input type="checkbox" checked id="inputee1_11" class="inputcheckbox" name="s[]" value="579130" />
            <label class="selectbox_label" for="inputee1_11">
                <strong>Record Online Service 4</strong>
            </label>
        </li>
        <li>
            <input type="checkbox" checked id="inputee1_12" class="inputcheckbox" name="s[]" value="578958" />
            <label class="selectbox_label" for="inputee1_12">
                <strong>Validate On-Device Servi...</strong>
            </label>
        </li>
        <li>
            <input type="checkbox" checked id="inputee1_13" class="inputcheckbox" name="s[]" value="581819" />
            <label class="selectbox_label" for="inputee1_13">
                <strong>Validate On-Device Servi...</strong>
            </label>
        </li>
        <li>
            <input type="checkbox" checked id="inputee1_14" class="inputcheckbox" name="s[]" value="583972" />
            <label class="selectbox_label" for="inputee1_14">
                <strong>Validate On-Device Servi...</strong>
            </label>
        </li>
        <li>
            <input type="checkbox" checked id="inputee1_15" class="inputcheckbox" name="s[]" value="579099" />
            <label class="selectbox_label" for="inputee1_15">
                <strong>Validate Online Service 1</strong>
            </label>
        </li>
        <li>
            <input type="checkbox" checked id="inputee1_16" class="inputcheckbox" name="s[]" value="581817" />
            <label class="selectbox_label" for="inputee1_16">
                <strong>Validate Online Service 2</strong>
            </label>
        </li>
        <li>
            <input type="checkbox" checked id="inputee1_17" class="inputcheckbox" name="s[]" value="581818" />
            <label class="selectbox_label" for="inputee1_17">
                <strong>Validate Online Service 3</strong>
            </label>
        </li>
        <li>
            <input type="checkbox" checked id="inputee1_18" class="inputcheckbox" name="s[]" value="578962" />
            <label class="selectbox_label" for="inputee1_18">
                <strong>Web View Service 1</strong>
            </label>
        </li>--%>
    </ul>
</div>
<script>

    $(document).ready(function () {
        function listFilter(header, list) {
            input = $("<input>").attr({ "id": "filter_services_text", "class": "filterinput inputnormalwide", "type": "text", "placeholder": "Type to begin filtering..." });
            clear = $("<span>").text(" clear").attr({ "id": "clear_services_filter", "style": "cursor:pointer" });

            $(input).insertBefore(header);
            $(clear).insertBefore(header);
            $("<br/>").insertBefore(header);


            $(clear).hide();

            $(input).change(function () {

                if ($(input).val().length > 0) {
                    $(clear).show();
                }
                else {
                    $(clear).hide();
                }

                var filter = $(this).val().toLowerCase();
                if (filter) {
                    $(list).find("label").each(function () {
                        if ($(this).text().toLowerCase().indexOf(filter) === -1 && !($(this).parent().hasClass("deleted"))) {
                            $(this).parent().slideUp();
                        } else if ($(this).text().toLowerCase().indexOf(filter) !== -1 && !($(this).parent().hasClass("deleted"))) {
                            $(this).parent().slideDown();
                        }
                    });
                } else {
                    $(list).find("label:not(:empty)").parent().slideDown();
                    if ($("#services_list>li>input:[id^='inputee']:not(:checked)").length > 0) {
                        $("#select_all_services").attr('checked', false);
                    } else {
                        $("#select_all_services").attr('checked', true);
                    }
                }
                return false;
            })
            .keyup(function () {
                $(this).change();
            });
        }
        listFilter($("#select_all_services"), $("#services_list"));
        $("#clear_services_filter").click(function (event) {
            $('#filter_services_text').val('');
            $('#filter_services_text').change();
        });

    });
    $("#select_all_services").live("change", function (event) {

        // This was added because the 'All type' checkbox wasn't having its checked attribute removed properly
        $(this).attr("checked", $(this).attr("checked") ? true : false);

        $($("#services_list>li>input:[id^='inputee']").filter(':visible')).attr('checked', $(this).is(':checked')).next().css('font-weight', $(this).is(':checked') ? 'bold' : 'normal');
    });

    $("#select_all_services").attr('checked', true);

    $('input:[id^="inputee"]').live("change", function (event) {
        var unchecked_present = true;
        $('input:[id^="inputee"]').each(function (i) {

            if (!$(this).is(':checked')) {
                unchecked_present = false;
            }

        });
        $("#select_all_services").attr('checked', unchecked_present);
        $(this).next().css('font-weight', $(this).is(':checked') ? 'bold' : 'normal');
    });

</script>
